package com.cyw.note.common;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class RespBean {
    private Integer status = 0;
    private String msg;
    private Object obj;
    /**
     * 成功
     */
    public static final int SUCCESS = 200;

    /**
     * 失败
     */
    public static final int FAIL = 500;

    public static RespBean build(){
       return new RespBean();
    }
    public static RespBean success(String msg){
        return new RespBean(SUCCESS,msg,null);
    }
    public static RespBean success(Object obj){
        return new RespBean(SUCCESS,"成功",obj);
    }

    public static RespBean success(){
        return new RespBean(SUCCESS,"操作成功",null);
    }

    public static RespBean success(String msg, Object obj){
        return new RespBean(SUCCESS,msg,obj);
    }

    public static RespBean error(String msg){
        return new RespBean(FAIL,msg,null);
    }

    public static RespBean error(){
        return new RespBean(FAIL,"操作失败",null);
    }

    public static RespBean error(String msg, Object obj){
        return new RespBean(FAIL,msg,obj);
    }

    private RespBean(Integer status, String msg, Object obj) {
        this.status = status;
        this.msg = msg;
        this.obj = obj;
    }

}

